import HttpService from '../../app/services/httpService.js';

class CpService extends HttpService {
    constructor($http, $q){
        super($http, $q)

        this.URL = this.baseUrl();

        this.OBJ = {
        	CpListUrl: this.URL + '/cp/lists?race_id=',
            CpListTimingUrl: this.URL + '/cp/lists?type=timing&race_id=',
            CpListCameraUrl: this.URL + '/cp/lists?type=camera&race_id=',
            CpCreateUrl: this.URL + '/cp/create?race_id=',
            CpDetailUrl: this.URL + '/cp/detail?cp_id=',
            CpUpdateUrl: this.URL + '/cp/update?cp_id=',
            CpDelUrl: this.URL + '/cp/del?race_id=',
            DeviceListUrl: this.URL + '/device/lists?&race_id=',
            TrelatedUrl: this.URL + '/race/getrelated?race_id=',
        }
    }

    /* 获取CP列表 */
    getCpList(headers, search) {
        return this.getRequest(this.OBJ.CpListUrl, headers, search);
    }

    /* 获取计时列表 */
    getCpListTiming(headers, search) {
        return this.getRequest(this.OBJ.CpListTimingUrl, headers, search);
    }

    getCpListCamera(headers, search) {
        return this.getRequest(this.OBJ.CpListCameraUrl, headers, search);
    }
    
    /* 创建CP点 */
    postCpCreate(params, headers, search) {
        return this.postRequest(this.OBJ.CpCreateUrl, params, headers, search);
    }
    
    /* 获取CP点详情 */
    getCpDetail(headers, search) {
        return this.getRequest(this.OBJ.CpDetailUrl, headers, search);
    }
    
    /* 更新CP点 */
    postCpUpdate(params, headers, search) {
        return this.postRequest(this.OBJ.CpUpdateUrl, params, headers, search);
    }
    
    /* 删除CP点 */
    postCpDel(params, headers, search) {
        return this.postRequest(this.OBJ.CpDelUrl, params, headers, search);
    }
    
    /* 获取绑定设备列表 */
    getDeviceList(headers, search) {
        return this.getRequest(this.OBJ.DeviceListUrl, headers, search);
    }

    /* 获取123赛事id */
    getTrelated(headers, search) {
        return this.getRequest(this.OBJ.TrelatedUrl, headers, search);
    }

}

export default CpService;